home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / SPMATE13.ZIP / GETFILE.FR$ / getfile.frm
Text File  |  1993-07-09  |  6KB  |  226 lines

  1. VERSION 2.00
  2. Begin Form GetFile 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Select a File"
  5.    Height          =   3885
  6.    Icon            =   0
  7.    Left            =   1005
  8.    LinkMode        =   1  'Source
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   3510
  11.    ScaleWidth      =   6285
  12.    Top             =   1200
  13.    Width           =   6375
  14.    Begin DriveListBox Drive1 
  15.       Height          =   315
  16.       Left            =   4785
  17.       TabIndex        =   3
  18.       Top             =   1800
  19.       Width           =   1215
  20.    End
  21.    Begin DirListBox Dir1 
  22.       Height          =   1815
  23.       Left            =   2280
  24.       TabIndex        =   2
  25.       Top             =   1455
  26.       Width           =   2265
  27.    End
  28.    Begin FileListBox File1 
  29.       Height          =   2175
  30.       Left            =   240
  31.       TabIndex        =   1
  32.       Top             =   1080
  33.       Width           =   1800
  34.    End
  35.    Begin CommandButton Command2 
  36.       Caption         =   "Cancel"
  37.       Height          =   375
  38.       Left            =   4935
  39.       TabIndex        =   5
  40.       Top             =   720
  41.       Width           =   1095
  42.    End
  43.    Begin CommandButton Command1 
  44.       Caption         =   "OK"
  45.       Default         =   -1  'True
  46.       Height          =   375
  47.       Left            =   4935
  48.       TabIndex        =   4
  49.       Top             =   240
  50.       Width           =   1095
  51.    End
  52.    Begin TextBox Text1 
  53.       Height          =   315
  54.       Left            =   1200
  55.       TabIndex        =   0
  56.       Text            =   "Text1"
  57.       Top             =   240
  58.       Width           =   3495
  59.    End
  60.    Begin Label Label5 
  61.       AutoSize        =   -1  'True
  62.       Caption         =   "Drives:"
  63.       Height          =   195
  64.       Left            =   4785
  65.       TabIndex        =   8
  66.       Top             =   1575
  67.       Width           =   615
  68.    End
  69.    Begin Label Label4 
  70.       AutoSize        =   -1  'True
  71.       Caption         =   "Directories:"
  72.       Height          =   195
  73.       Left            =   2280
  74.       TabIndex        =   7
  75.       Top             =   1200
  76.       Width           =   990
  77.    End
  78.    Begin Label Label3 
  79.       AutoSize        =   -1  'True
  80.       Caption         =   "Files:"
  81.       Height          =   195
  82.       Left            =   240
  83.       TabIndex        =   10
  84.       Top             =   840
  85.       Width           =   465
  86.    End
  87.    Begin Label Label1 
  88.       AutoSize        =   -1  'True
  89.       Height          =   195
  90.       Left            =   2160
  91.       TabIndex        =   6
  92.       Top             =   750
  93.       Width           =   2055
  94.    End
  95.    Begin Label Label2 
  96.       AutoSize        =   -1  'True
  97.       Caption         =   "File Name:"
  98.       Height          =   195
  99.       Left            =   240
  100.       TabIndex        =   9
  101.       Top             =   240
  102.       Width           =   915
  103.    End
  104. End
  105. 'Declarations for GETFILE.FRM
  106.  
  107. Const TEXTFLAG = 0
  108. Const FILEFLAG = 1
  109. Const DIRFLAG = 2
  110.  
  111. Dim SelectFlag As Integer
  112.  
  113. Sub Command1_Click ()
  114.    On Error GoTo ErrorTrap
  115.  
  116.    If SelectFlag = TEXTFLAG Then
  117.       File1.FileName = Text1.Text
  118.       If FileSelected = True Then
  119.          On Error GoTo 0
  120.          Unload GetFile
  121.          Exit Sub
  122.       End If
  123.       Dir1.Path = File1.Path
  124.    ElseIf SelectFlag = DIRFLAG Then
  125.       Dir1.Path = Dir1.List(Dir1.ListIndex)
  126.       Dir1_Change
  127.    Else
  128.       If Right$(Dir1.Path, 1) = "\" Then
  129.          FullFilePath = Dir1.Path + Text1.Text
  130.       Else
  131.          FullFilePath = Dir1.Path + "\" + Text1.Text
  132.       End If
  133.       FileSelected = True
  134.       Unload GetFile
  135.    End If
  136.    Exit Sub
  137.  
  138. ErrorTrap:
  139.    Beep
  140.    Resume Next
  141. End Sub
  142.  
  143. Sub Command2_Click ()
  144.    Unload GetFile
  145. End Sub
  146.  
  147. Sub Dir1_Change ()
  148.    FillLabel1
  149.    File1.FileName = Dir1.Path + "\" + File1.Pattern
  150.    Drive1.Drive = Dir1.Path
  151.    Text1.Text = File1.Pattern
  152.    SelectFlag = DIRFLAG
  153. End Sub
  154.  
  155. Sub Dir1_Click ()
  156.    SelectFlag = DIRFLAG
  157. End Sub
  158.  
  159. Sub Drive1_Change ()
  160.    Dir1.Path = Drive1.Drive
  161.    Text1.Text = File1.Pattern
  162.    SelectFlag = DIRFLAG
  163. End Sub
  164.  
  165. Sub File1_Click ()
  166.    Text1.Text = File1.FileName
  167.    SelectFlag = FILEFLAG
  168. End Sub
  169.  
  170. Sub File1_DblClick ()
  171.    If SelectFlag = TEXTFLAG Then
  172.       FullFilePath = File1.Path + "\" + File1.FileName
  173.    Else
  174.       If Right$(Dir1.Path, 1) = "\" Then
  175.          FullFilePath = Dir1.Path + Text1.Text
  176.       Else
  177.          FullFilePath = Dir1.Path + "\" + Text1.Text
  178.       End If
  179.    End If
  180.  
  181.    FileSelected = True
  182.    Unload GetFile
  183. End Sub
  184.  
  185. Sub FillLabel1 ()
  186.    Label1.Caption = Dir1.Path
  187.    If Label1.Width > 2055 Then
  188.       a$ = Left$(Dir1.Path, 3)
  189.       b$ = Mid$(Dir1.Path, 4)
  190.       Do While InStr(b$, "\")
  191.          b$ = Mid$(b$, InStr(b$, "\") + 1)
  192.       Loop
  193.       Label1.Caption = a$ + "...\" + b$
  194.    End If
  195. End Sub
  196.  
  197. Sub Form_Load ()
  198.    GetFile.Left = (Screen.Width - GetFile.Width) / 2
  199.    GetFile.Top = (Screen.Height - GetFile.Height) / 2
  200.  
  201.    If FullFilePath <> "" Then
  202.       Tmp$ = FullFilePath
  203.       Do Until Right$(Tmp$, 1) = "\"
  204.          Tmp$ = Left$(Tmp$, Len(Tmp$) - 1)
  205.       Loop
  206.       Tmp$ = Tmp$ + WILDCARD$
  207.       File1.FileName = Tmp$
  208.       Dir1.Path = File1.Path
  209.    End If
  210.  
  211.    File1.Pattern = WILDCARD$
  212.    FillLabel1
  213.    Text1.Text = File1.Pattern
  214.    SelectFlag = DIRFLAG
  215.    FileSelected = False
  216. End Sub
  217.  
  218. Sub Form_Resize ()
  219.    Text1.SetFocus
  220. End Sub
  221.  
  222. Sub Text1_Change ()
  223.    SelectFlag = TEXTFLAG
  224. End Sub
  225.  
  226.